package com.yyx.springcloud.controller;

import com.yyx.springcloud.pojo.Payment;
import com.yyx.springcloud.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

/**
 * ClassName: OrderController
 * Package: com.yyx.springcloud.controller
 * Description:
 *
 * @Author: yyx
 * @Create: 2025/7/23 - 16:35
 */
@Slf4j
@RestController
@RequestMapping("/consumer")
public class OrderController {
    public static final String PAYMENT_URL="http://CLOUD-PAYMENT-SERVICE";
    @Autowired
    private RestTemplate restTemplate;
    @GetMapping("/payment/get/{id}")
    public Result<Payment> getPayment(@PathVariable("id") Long id){
        return restTemplate.getForObject(PAYMENT_URL+"/payment/get/"+id,Result.class);
    }
    @PostMapping("/payment/create")
    public Result<Payment> create(@RequestBody Payment payment){
        return restTemplate.postForObject(PAYMENT_URL+"/payment/create/",payment,Result.class);
    }
}
